﻿using System;
namespace Colors.Xroad.Eu {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="Settings", Namespace="http://colors.x-road.eu/", Target=typeof(Settings))]
    public class SettingsSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected Settings clazz;
        
        public SettingsSerializer(Settings clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXmlAttributes(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXmlAttributes(Writer);
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("alpha_component");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdShort(((short)(clazz.AlphaComponent))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXmlAttributes(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXmlAttributes(Reader);
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="alpha_component") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>Settings>alpha_component");
                }
                clazz.AlphaComponent = new global::Xtee.Core.Schema.XsdShort(Reader.ReadElementString("alpha_component")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>Settings>alpha_component", Reader.LocalName);
            }
        }
    }
}
